/****************************************************************************************
*            . .. .                                                                     *
*                    ...                                                                *
*                       .":                                                             *
*   .                      u                                                            *
* ..     .:uxkkOkkx=.      "k'                                                          *
*.     "k00O0ko==uk00x'     OO.                       IBE-CAE                           *
*'   .xK0O00: 'xx" x0Ku    .O0:     Copyright (C) by Internet Based Engineering         *
*   .O0OO00= oKOk:"O0O'    :00=                 All rights reserved.                    *
*.  =0OOO00" =OOO0Oo'     =0OO:                      www.ibe.cn                         *
*.  u0OOOO0O'          .o00OOO.                                                         *
* . :KOOOOO00xu=:::=uok00OOOO"                                                          *
*   .x00OOOOOO0000000OOOOOOx.                                                           *
*    .u00OOOOOOOOOOOOOOOOO=                                                             *
*      .ukOOOOOOOOOOOOku'                                                               *
*          .'::==::'.                                                                   *
****************************************************************************************/

#ifndef IBE_MACRO_H_
#define IBE_MACRO_H_

/*!
 * @file IBE_Macro.h
 *
 * @brief 自定义宏
 * @author liupeng
 */

#include <string.h>

#define IBE_AbstractTypeMacro(thisNamespace,thisClass,superNamespace,superclass,thisClassName) \
  public: \
  typedef superNamespace::superclass Superclass; \
  static int IsTypeOf(const char* name) \
  { \
    if ( !strcmp(thisClassName,name) ) \
    { \
      return 1; \
    } \
    return Superclass::IsTypeOf(name); \
  } \
  int IsA( const char* name ) override \
  { \
    return this->thisClass::IsTypeOf(name); \
  } \
  static thisNamespace::thisClass* SafeDownCast(ibe_common::IBE_ObjectBase* o) \
  { \
    if ( o && o->IsA(thisClassName) ) \
    { \
      return static_cast<thisNamespace::thisClass*>(o); \
    } \
    return nullptr; \
  } \
  protected: \
  const char* GetClassNameInternal() const override \
  { \
    return thisClassName; \
  }

#define IBE_TypeMacro(thisNamespace,thisClass,superNamespace,superclass) \
  IBE_AbstractTypeMacro(thisNamespace,thisClass,superNamespace,superclass,#thisNamespace"::"#thisClass) \
  public:

#endif // IBE_MACRO_H_